<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('合同列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>总院编号：</label>
                                <input type="text" name="instituteNum"/>
                            </li>
                            <li>
                                <label>分院编号：</label>
                                <input type="text" name="branchNum"/>
                            </li>
                            <li>
                                <label>合同名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>业&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;主：</label>
                                <select name="owner" class="form-control m-b" th:with="type=${@owner.selectOwnerList()}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.name}" th:value="${dict.name}"></option>
                                </select>
                            </li>
                            <li>
                                <label>省&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;份：</label>
                                <select name="province" th:with="type=${@dict.getType('sys_province')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>

                            <li>
                                <label>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;区：</label>
                                <select name="zone" th:with="type=${@dict.getType('sys_zone')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>签订时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginSignTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endSignTime]"/>
                            </li>
                            <li>
                                <label>项目执行情况：</label>
                                <select name="status" th:with="type=${@dict.getType('sys_project_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>


                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:contract:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:contract:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:contract:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />

     <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:contract:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:contract:remove')}]];
        var ownerDatas = [[${@dict.getType('tmp_ss')}]];
        var provinceDatas = [[${@dict.getType('sys_province')}]];
        var zoneDatas = [[${@dict.getType('sys_zone')}]];
        var statusDatas = [[${@dict.getType('sys_project_status')}]];
        var prefix = ctx + "system/contract";

        var zongyuan = [[${@permission.hasPermi('system:institute:list')}]];
        var xiangqing  = [[${@permission.hasPermi('system:contract:view2')}]];
        var fenyuan = [[${@permission.hasPermi('system:branch:list')}]];
        var renyuan = [[${@permission.hasPermi('system:staff:list')}]];
        var daokuan = [[${@permission.hasPermi('system:record:list')}]];
        var caigou = [[${@permission.hasPermi('system:purchase:list')}]];



        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "合同",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },

                {
                    field: 'branchNum',
                    title: '分院编号',
                    width: 110,
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,12);
                    }
                },
                {
                    field: 'name',
                    title: '合同名称',
                    width: 376,
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,27);
                    }
                },
                {
                    field: 'owner',
                    title: '业主',
                    width: 241,
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,17);
                    }
                },
                {
                    field: 'signTime',
                    title: '签订时间',
                    width: 90,
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'money',
                    title: '合同额',
                    formatter: function(value, row, index) {
                        return row.money.toFixed(4);
                    }
                },
                {
                    field: 'managerCost',
                    title: '管理费',
                    formatter: function(value, row, index) {
                        return row.managerCost.toFixed(4);
                    }
                },
                    {
                        field: 'payMoney',
                        title: '支付金额',
                        formatter: function(value, row, index) {
                            return row.payMoney.toFixed(4);
                        }
                    },
                    {
                        field: 'toMoney',
                        title: '到款额',
                        formatter: function(value, row, index) {
                            return row.toMoney.toFixed(4);
                        }
                    },
                    {
                        field: 'toMoney',
                        title: '总盘剩余资金' ,
                        formatter:function (value, row, index) {
                        // （合同额-管理费）×到款比例-已支付金额总额
                            return ((row.money-row.managerCost)*(row.toMoney/row.money) - row.payMoney).toFixed(4);
                        }
                    },
                {
                    field: 'status',
                    title: '项目执行情况',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'left',

                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + xiangqing + '" href="javascript:void(0)" onclick="detail0(\'' + row.id + '\')"><i class="fa fa-search"></i>查看</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + zongyuan + '" href="javascript:void(0)" onclick="detail(\'' + row.id + '\')"><i class="fa"></i>总院</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + fenyuan + '" href="javascript:void(0)" onclick="detail1(\'' + row.id + '\')"><i class="fa"></i>分院</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + caigou + '" href="javascript:void(0)" onclick="detail2(\'' + row.id + '\')"><i class="fa"></i>采购</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + daokuan + '" href="javascript:void(0)" onclick="detail3(\'' + row.id + '\')"><i class="fa"></i>到款</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + renyuan + '" href="javascript:void(0)" onclick="detail4(\'' + row.id + '\')"><i class="fa"></i>人员</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        /*字典列表-详细*/
        function detail0(dictId) {
            var url = 'system/contract/detail/' + dictId;
            $.modal.open("查看合同", url,1200,800);
        }
        function detail(dictId) {
            var url = 'system/institute/' + dictId;
            $.modal.openTab("总院信息", url);
        }
        /*字典列表-详细*/
        function detail1(dictId) {
            var url = 'system/branch/' + dictId;
            $.modal.openTab("分院信息", url);
        }
        function detail2(dictId) {
            var url = 'system/purchase/' + dictId;
            $.modal.openTab("采购信息", url);
        }
        function detail3(dictId) {
            var url = 'system/record/' + dictId;
            $.modal.openTab("到款信息", url);
        }
        function detail4(dictId) {
            var url = 'system/staff/' + dictId;
            $.modal.openTab("人员信息", url);
        }
    </script>
</body>
</html>